<template>
	<view class="home-wrap u-m-b-20" :style="{ 'background':'#f8f8f8 url('+HTTP_IMG_URL()+'/merchant/merchant_bg.png) no-repeat','background-size': '100%'}">
		<base-nav-bar :backIconColor="'#fff'" :isBack="true" :background="{'background':'url('+HTTP_IMG_URL()+'/merchant/merchant_bg.png) no-repeat','background-size': '100%'}">
			<text
				slot="content"
				style="color: #fff; width: 100%; text-align: center;padding-left: 20rpx;"
			>
				向上生活
			</text>
		</base-nav-bar>
		<!-- 商家简介 -->
		<view class="merchant-title u-flex u-flex-column u-flex-items-center u-p-20 u-m-l-20 u-m-r-20">
			<view class="merchant-main-title u-m-t-50 u-m-b-40">
				<view class="u-m-b-10 u-m-t-10 u-font-50">乐享运动 健康生活</view>
			</view>
			<view class="merchant-sub-title u-flex u-flex-center u-flex-content-start u-col-center">
				<view class="merchant-sub-title-btn">向上生活伴您一路向前</view>
			</view>
		</view>
		<view class="content-box u-p-20 u-m-t-30 u-m-l-40 u-m-r-40">
			<!-- grid商家功能模块 -->
			<view class="u-flex u-flex-items-center u-flex-start u-flex-wrap">
				<view class="pay-item u-flex u-flex-column u-flex-items-center u-flex-center u-m-t-16 u-m-b-20" v-for="(baseListItem,baseListIndex) in baseList" :key="baseListIndex" @click="baseListItem.name!='二维码核销'?jump(baseListItem.routerUrl):scanCodeHandler()" v-if="baseListItem.isShow">
					<image :src="baseListItem.iconUrl" class="u-content-grid-img" :style="{'width':'96rpx','height':'96rpx'}"></image>
					<text class="grid-text u-font-26">{{ baseListItem.name }}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>

import { mapGetters } from 'vuex';
import { HTTP_IMG_URL } from '../../config/app.js'
import BaseNavBar from "../../components/BaseNavBar.vue";

export default {
	components: {
		BaseNavBar
	},
	data() {
		return {
			goodsInfo: {
				images: []
			},
			baseList:[]
		};
	},
	computed: {
		...mapGetters(['isLogin','userInfo']),
		
	},
	onPullDownRefresh() {
	
	},
	
	onShow() {
		if(!this.isLogin){
		
		}
		
	},
	onHide() {
	},
	onLoad() {
		console.log("====this.userInfo",this.userInfo)
		this.baseList = [
			{
				iconUrl:this.HTTP_IMG_URL()+'/merchant/icon/merchant_info.png',
				routerUrl:'/pages-merchant/merchant/merchantInfo',
				name:'商家信息',
				isShow:this.userInfo.is_examine=='1'?false:true
			},
			{
				iconUrl:this.HTTP_IMG_URL()+'/merchant/icon/curriculum_management.png',
				routerUrl:'/pages-merchant/merchant/courseList',
				name:'课程管理',
				isShow:this.userInfo.is_examine=='1'?false:true
			},
			{
				iconUrl:this.HTTP_IMG_URL()+'/merchant/icon/commodity_management.png',
				routerUrl:'/pages-merchant/goods/goodsList',
				name:'商品管理',
				isShow:this.userInfo.is_examine=='1'?false:true
			},
			{
				iconUrl:this.HTTP_IMG_URL()+'/merchant/icon/teacher_management.png',
				routerUrl:'/pages-merchant/manage/teacherList',
				name:'老师管理',
				isShow:this.userInfo.is_examine=='1'?false:true
			},
			{
				iconUrl:this.HTTP_IMG_URL()+'/merchant/icon/curriculum_management.png',
				routerUrl:'/pages-merchant/class/courseList',
				name:'课程包管理',
				isShow:this.userInfo.is_examine=='1'?false:true
			},
			{
				iconUrl:this.HTTP_IMG_URL()+'/merchant/icon/curriculum_schedule.png',
				routerUrl:'/pages-merchant/class/classList',
				name:'课程表',
				isShow:this.userInfo.is_examine=='1'?false:true
			},
			{
				iconUrl:this.HTTP_IMG_URL()+'/merchant/icon/recharge_audit.png',
				routerUrl:'/pages-merchant/wallet/rechargeReview',
				name:'充值审核',
				isShow:this.userInfo.is_examine=='1'?false:true
			},
			{
				iconUrl:this.HTTP_IMG_URL()+'/merchant/icon/recharge_audit.png',
				routerUrl:'/pages-merchant/class/rechargeReview',
				name:'充值课程包',
				isShow:this.userInfo.is_examine=='1'?false:true
			},
			// {
			// 	iconUrl:this.HTTP_IMG_URL()+'/merchant/icon/course_order.png',
			// 	routerUrl:'/pages-merchant/class/buyClassBack',
			// 	name:'购买课程包',
			// 	isShow:true
			// },
			// {
			// 	iconUrl:this.HTTP_IMG_URL()+'/merchant/icon/issue_coupons.png',
			// 	routerUrl:'/pages-merchant/coupon/couponAdd',
			// 	name:'发放优惠券',
			// 	isShow:true
			// },
			// {
			// 	iconUrl:this.HTTP_IMG_URL()+'/merchant/icon/stored_integral.png',
			// 	routerUrl:'/pages-merchant/points/prestoreIntegral',
			// 	name:'预存积分',
			// isShow:true
			// },
			{
				iconUrl:this.HTTP_IMG_URL()+'/merchant/icon/merchant_wallet.png',
				routerUrl:'/pages-merchant/wallet/wallet',
				name:'商家钱包',
				isShow:this.userInfo.is_examine=='1'?false:true
			},
			{
				iconUrl:this.HTTP_IMG_URL()+'/merchant/icon/integral_cancellation.png',
				routerUrl:'/pages-merchant/points/integralCancellation',
				name:'积分核销',
				isShow:this.userInfo.is_examine=='1'?false:true
			},
			{
				iconUrl:this.HTTP_IMG_URL()+'/merchant/icon/fixed_point_consumption.png',
				routerUrl:'/pages-merchant/points/fixedIntegral',
				name:'固定积分消费',
				isShow:this.userInfo.is_examine=='1'?false:true
			},
			{
				iconUrl:this.HTTP_IMG_URL()+'/merchant/icon/qr_code_verification.png',
				name:'二维码核销',
				isShow:true
			},
			{
				iconUrl:this.HTTP_IMG_URL()+'/merchant/icon/course_order.png',
				routerUrl:'/pages-merchant/order/orderList',
				name:'课程订单',
				isShow:true
			},
			{
				iconUrl:this.HTTP_IMG_URL()+'/merchant/icon/active_write_off.png',
				routerUrl:'/pages-merchant/order/activityList',
				name:'活动核销',
				isShow:this.userInfo.is_examine=='1'?false:true
			},
			
			{
				iconUrl:this.HTTP_IMG_URL()+'/merchant/icon/course_order.png',
				routerUrl:'/pages-merchant/order/goodsOrderList',
				name:'商品订单',
				isShow:true
			},
			{
				iconUrl:this.HTTP_IMG_URL()+'/merchant/icon/course_order.png',
				routerUrl:'/pages-merchant/class/orderList',
				name:'课程包订单',
				isShow:true
			},
		]
	},
	methods: {
		HTTP_IMG_URL() {
			return HTTP_IMG_URL
		},
		logout(){
			this.$refs.deletpopupAddress.$refs.deletpopup.open()
		},
		denglu() {
			this.$refs.deletpopupAddress.$refs.deletpopup.close()
		},
		// 路由跳转
		jump(path, parmas) {
			uni.navigateTo({
				url: path,
				query: parmas
			});
		},
		loginOut() {
			let that = this;
			that.$u.toast('退出成功')
			that.$refs.deletpopupAddress.$refs.deletpopup.close();
			that.$store.dispatch("logout");
		},
		scanCodeHandler(){
			let that = this;
				// 调起条码扫描
			uni.scanCode({
				onlyFromCamera: true, // 是否只能从相机扫码，不允许从相册选择图片
				scanType: ['qrCode'], // 扫码类型 qrCode二维码
				autoZoom: false, 	  // 是否启用自动放大，默认启用
				success: function (res) {
					console.log(`扫码结果：${JSON.stringify(res,null,2)}`);
					that.parseQRCode(res);
				},
				fail: function (err) {
					console.log(`错误：${err}`);
				},
				complete: function (data) {
					console.log('擦屁股！');
				}
			});
		},
		// 解析二维码，处理业务
		parseQRCode(data){
			uni.vibrateShort();					// 震动提示
			this.jump(data.result)
		}
	}
};
</script>

<style lang="scss" scoped>
/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
.home-wrap {
	min-height: 100vh;
}
.kehu-item {
	border-radius: 20rpx;
	width: 100%;
	.swipers{
		width: 100%;
	}
}
.nickname{
	font-size: 34rpx;
	font-weight: bold;
}
.content-box{
	background: #FFFFFF;
	border-radius: 30rpx;
	min-height: 50vh;
	.pay-item{
		width: 25%;
	}
}
.merchant-title {
	.merchant-main-title {
		width: 100%;
		color: #fff;
		padding: 6rpx 0rpx;
		text-align: center;
	}
	
	.merchant-sub-title {
		width: 60%;
		background: #E9FF2B;
		color: #1989fa;
		padding: 9rpx 0rpx;
		text-align: center;
		border-radius: 40rpx;
		text-align: center;
		.merchant-sub-title-btn{
			color: #00BB65;
		}
	}
}
</style>
